package org.tp8.sampleapp.service.facade;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.tp8.sampleapp.exc.SampleAppException;
import org.tp8.sampleapp.model.Teacher;
import org.tp8.sampleapp.rule.model.RuleModelWrapper;
import org.tp8.sampleapp.service.intf.TeacherService;

/**
 * The Class SchoolFacade.
 */
@Service("teacherFacade")
public class TeacherFacade extends AbstractFacade {

	/**
	 * The teacher service.
	 */
	@Autowired
	private TeacherService teacherService;

	/**
	 * Find all.
	 * 
	 * @return the collection
	 * @throws SampleAppException
	 *             the sample app exception
	 */
	public Collection<Teacher> findAll() throws SampleAppException {
		Pageable pageable = new PageRequest(0, 100);
		Page<Teacher> page = teacherService.findAll(pageable);
		return page.getContent();
	}

	/**
	 * Save.
	 * 
	 * @param teacher
	 *            the teacher
	 * @return the teacher
	 * @throws SampleAppException
	 *             the sample app exception
	 */
	public Teacher save(Teacher teacher) throws SampleAppException {
		return teacherService.save(teacher);
	}

	/**
	 * Find one.
	 * 
	 * @param id
	 *            the id
	 * @return the teacher
	 * @throws SampleAppException
	 *             the sample app exception
	 */
	public Teacher findOne(Long id) throws SampleAppException {
		return teacherService.findOne(id);
	}

	/**
	 * Delete.
	 * 
	 * @param id
	 *            the id
	 * @throws SampleAppException
	 *             the sample app exception
	 */
	public void delete(Long id) throws SampleAppException {
		teacherService.delete(id);
	}

	/**
	 * Validate.
	 * 
	 * @param sessionName
	 *            the session name
	 * @param entity
	 *            the entity
	 * @return the rule model wrapper
	 * @throws SampleAppException
	 *             the sample app exception
	 */
	public RuleModelWrapper validate(String sessionName, Teacher entity)
			throws SampleAppException {
		return teacherService.validate(entity);
	}

	/**
	 * Count.
	 * 
	 * @return the long
	 * @throws SampleAppException
	 */
	public long count() throws SampleAppException {
		return teacherService.count();
	}

}
